import LStorage from './LStorage'

const state = {
  status: false,
  administrator: null,
  token: null,
  authorization: 'Basic aHVubGlhbjpodW5saWFuMTIzcGFzcw=='
}

const mutations = {
  LOGIN_SUCCESS (state, payload) {
    state.login.status = true
    state.login.administrator = payload.administrator
    state.login.token = payload.token
    state.login.authorization = payload.token.token_type + ' ' + payload.token.access_token
    LStorage.setItem('state', state)
  },
  LOGOUT_SUCCESS (state) {
    state.login.status = false
    state.login.administrator = null
    state.login.token = null
    state.login.authorization = 'Basic aHVubGlhbjpodW5saWFuMTIzcGFzcw=='
  }
}

export default {
  state,
  mutations
}
